1. Field of the Invention
This invention relates generally to methods and apparatus for sensing the position of a moving part. In particular, the invention relates to a dynamically tracking threshold for maintaining the reliability of an optical sensor.
2. Description of the Related Art
Position sensors are typically used in machines to monitor the physical state of a moving mechanical component of an automated system. For example, the exact position of a moving part may need to be determined to establish an xe2x80x9conxe2x80x9d or xe2x80x9coffxe2x80x9d control signal for mechanical applications, such as an end stop or travel limit for an X- or Y-motor to move a cartridge gripper of a robotic system loading and unloading magnetic tapes into and from a tape drive or cartridge cell. In such applications, the position sensor determines when the tape cartridge has reached the desired physical location within the tape drive (or the cartridge cell) and the sensor""s output is used both to stop the gripper motor and to trigger the next operation step within the functional logic of the system. For instance, the tape cartridge""s advance is stopped and data stored in the tape are accessed by a computer.
Motion detectors used in the prior art to monitor mechanical motion typically consist of mechanical switches and/or optical sensors. Both types of devices require periodic maintenance or replacement to preserve the desired level of reliability. As one skilled in the art would readily appreciate, mechanical switches include moving parts and are prone to contact bounce and malfunction due to early life failure of any moving part in the switch.
Optical sensors, which consist of light sources and detectors, are often utilized to overcome these problems, but they are also susceptible to failures caused by problems inherent in the nature of their components. For example, optical sensors tend to become unreliable as a result of large changes in ambient light, misalignments between the light source and the detector, reduced light levels caused by dirt or debris accumulation, reduced light levels caused by the aging of the internal light sources, and manufacturing differences in sensitivity between devices. Thus, even though optical sensors are more immune than mechanical switches to mechanical noise and failure, their reliability remains uncertain under normal operating conditions.
The operation of an optical sensor is based on detecting the intensity of a light beam emitted by a light source (such as a light emitting diode, xe2x80x9cLEDxe2x80x9d) with a light detector (such as a phototransistor, xe2x80x9cPTRxe2x80x9d) aligned with the optical path of the beam. One detection approach, often referred to in the art as xe2x80x9cthrough-beam,xe2x80x9d involves a first normal state wherein the light is received by the detector at a relatively high intensity level directly from the source. A change of state is established when the light beam is blocked in its optical path toward the detector by a moving part, thereby causing the intensity measured at the detector to vary to a relatively lower value. Another approach, often referred to as xe2x80x9creflective,xe2x80x9d involves a first normal state wherein the light is directed away from the detector, which correspondingly measures a relatively low intensity level. A change of state is established when the light beam is reflected toward the detector by the moving part, thereby causing the intensity measured at the detector to vary to a relatively higher value. In either system, the accuracy of the operation of the detector is predicated upon its ability to correctly determine when a change of state has occurred as a result of the present location of the moving part.
A typical through-beam embodiment 10 of optical-sensor apparatus is illustrated in FIGS. 1A and 1B (prior art). An LED 12, appropriately grounded through a system ground G, is energized by a source voltage V to produce a light beam B. The beam is aimed, either directly or by reflection, at a PTR 14 that produces an analog output 16 which is a function of the intensity of the light beam B, as illustrated in FIG. 2. When a moving part crosses the path of the light beam B, it interrupts its normal path toward the detector 14 and correspondingly causes a significant drop in its output. Thus, the peak 18 of the analog amplitude curve 16 illustrated in FIG. 2 (prior art) corresponds to a minimum amount of light being blocked by the moving part and a maximum amount of light being received by the detector 14. Conversely, the low value of the amplitude curve corresponds to a maximum amount of light being blocked by the moving part and a minimum amount of light being received by the detector 14.
The output 16 of the detector 14 is typically used as the input to a comparator 20 (FIG. 1A) or a logic gate, such as a Schmitt trigger 20xe2x80x2 (FIG. 1B). As illustrated in FIG. 3A (prior art), an arbitrarily fixed detection threshold 22 is used to create a digital logic signal 24 that corresponds to the analog output 16 of the optical sensor. The resulting digital logic signal 24 changes state when the sensor""s analog output 16 crosses the threshold level 22, as shown in FIGS. 3A and 3B (prior art).
When a sufficiently large decrease occurs in the ability of the detector 14 to sense the light emitted by the LED, a total loss of detection may result if the peak 18 of the output 16 remains below the detection threshold 22, as illustrated in FIG. 4A (prior art). Correspondingly, the digital logic signal 24 becomes inoperably fixed at a single xe2x80x9clowxe2x80x9d or xe2x80x9c0xe2x80x9d logic state, as shown in FIG. 4B. This condition can result, for example, from partial blockage of the light source 12 or the detector 14 caused by debris accumulation, from a decrease in the output characteristics of the light source, or from a change in the alignment of the detector 14 with respect to the light source 12. In a reflective embodiment of optical-sensor apparatus (not illustrated in the figures), this problem can similarly result from a decrease in the reflectivity of the moving target.
Similar problems can arise when an increase in the light sensed by the detector 14 occurs to the point where the minimum amplitude 26 of the detector output 16 is always higher than the threshold 22, as illustrated in FIG. 5A, This can happen, for example, when the ambient or background light is too high, or when the light source 12 is supplied with too much current that yields a greater than rated light beam B. In a reflective embodiment, this problem can result from an increase in ambient reflectivity. In any of these cases, the digital logic signal 24 becomes inoperably fixed at a single xe2x80x9chighxe2x80x9d or xe2x80x9c1xe2x80x9d logic state, as shown in FIG. 5B.
In view of the foregoing, it is clear that the conventional fixed detection threshold used with prior-art optical sensors is inadequate to provide maintenance-free, reliable, long-term service under variable operating conditions. Some approaches have been disclosed in U.S. Pat. Nos. 5,898,170 and 5,739,524 to improve similar problems, but they are limited to specific optical-sensor applications. Accordingly, there is still a need for an improved approach of general application to setting the detection-threshold level of an optical sensor such that it reliably determines the logical state of the sensors under variable operating conditions.
The primary, general objective of this invention is a method and apparatus for reducing failures associated with optical sensors in automated systems, thereby reducing downtime, maintenance and repair costs.
Another objective of the invention is a method and apparatus that provide dynamically a detection threshold that is always bound by the maximum and minimum levels of the sensor output signal, so as to produce a correspondingly consistent digital logic signal.
Another goal is an invention that is suitable for relatively simple incorporation within existing robotic equipment.
Still another goal is a method and apparatus that can be carried out while advantageously using hardware already present in the automated system.
A final objective is an approach that can be implemented easily and economically according to the above stated criteria.
Therefore, according to these and other objectives, the invention consists of dynamically calibrating the optical sensor by measuring the maximum and minimum levels of the analog output produced by the light detector and setting the detection threshold of the sensor at an intermediate level between the two. For example, the new threshold may be set at a level halfway between the minimum and maximum output produced by the detector. The new detection threshold thus established is used currently as the voltage level (or current level, depending on the variable being monitored) that yields a change in the digital logic signal that determines the xe2x80x9chighxe2x80x9d or xe2x80x9clowxe2x80x9d state of the sensor.
The invention may be implemented through firmware control using analog-to-digital converter (ADC) hardware already embedded in the system. The analog output from the light detector is measured and converted to a digital signal that represents the magnitude of the analog signal (voltage or current). The digital signal is then compared through microprocessor firmware to the present detection threshold to determine the logic state of the optical sensor. The sensor is calibrated by reading the analog level when the optical path of the light beam is both open and blocked. A new detection threshold is then established by interpolation between the two measurements so generated and the detection threshold value stored by firmware is updated accordingly. Thus, the firmware dynamically compensates for any changes in the analog output characteristics of the sensor.
Alternatively, the invention may be implemented using digital-to-analog converter (DAC) hardware that may also be already present in the system. In this case, the fixed threshold is replaced with a DAC output under firmware control. The analog output from the optical detector is compared to the analog signal produced by the DAC to yield a digital signal that represents the logic state of the optical sensor. The sensor is calibrated by changing the output of the DAC through firmware control to determine the analog values that match the detector""s analog output when the optical path of the light beam is both open and blocked. A new detection threshold level is then established by interpolation between the two measurements so generated and the old detection threshold stored by firmware is updated accordingly. Thus, the firmware of the system again dynamically compensates for any changes in the analog output characteristics of the sensor.
Various other purposes and advantages of the invention will become clear from its description in the specification that follows and from the novel features particularly pointed out in the appended claims. Therefore, to the accomplishment of the objectives described above, this invention consists of the features hereinafter illustrated in the drawings, fully described in the detailed description of the preferred embodiment and particularly pointed out in the claims. However, such drawings and description disclose only some of the various ways in which the invention may be practiced.